package com.ruoyi.device.controller;

import java.util.List;
import java.io.IOException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.device.domain.TModelcamgroup;
import com.ruoyi.device.service.ITModelcamgroupService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 摄像头分组Controller
 * 
 * @author li
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/modelcamgroup")
@Tag(name = "摄像头分组", description = "摄像头分组相关操作API")
public class TModelcamgroupController extends BaseController
{
    @Autowired
    private ITModelcamgroupService tModelcamgroupService;

    /**
     * 查询摄像头分组列表
     */
    @Operation(summary = "查询摄像头分组列表", description = "查询摄像头分组列表")
    @RequiresPermissions("ruoyi-device:modelcamgroup:list")
    @GetMapping("/list")
    public TableDataInfo list(TModelcamgroup tModelcamgroup)
    {
        startPage();
        List<TModelcamgroup> list = tModelcamgroupService.selectTModelcamgroupList(tModelcamgroup);
        return getDataTable(list);
    }

    /**
     * 导出摄像头分组列表
     */
    @Operation(summary = "导出摄像头分组列表", description = "导出摄像头分组列表")
    @RequiresPermissions("ruoyi-device:modelcamgroup:export")
    @Log(title = "摄像头分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TModelcamgroup tModelcamgroup)
    {
        List<TModelcamgroup> list = tModelcamgroupService.selectTModelcamgroupList(tModelcamgroup);
        ExcelUtil<TModelcamgroup> util = new ExcelUtil<TModelcamgroup>(TModelcamgroup.class);
        util.exportExcel(response, list, "摄像头分组数据");
    }

    /**
     * 获取摄像头分组详细信息
     */
    @Operation(summary = "获取摄像头分组详细信息", description = "获取摄像头分组详细信息")
    @RequiresPermissions("ruoyi-device:modelcamgroup:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tModelcamgroupService.selectTModelcamgroupById(id));
    }

    /**
     * 新增摄像头分组
     */
    @Operation(summary = "新增摄像头分组", description = "新增摄像头分组")
    @RequiresPermissions("ruoyi-device:modelcamgroup:add")
    @Log(title = "摄像头分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TModelcamgroup tModelcamgroup)
    {
        return toAjax(tModelcamgroupService.insertTModelcamgroup(tModelcamgroup));
    }

    /**
     * 修改摄像头分组
     */
    @Operation(summary = "修改摄像头分组", description = "修改摄像头分组")
    @RequiresPermissions("ruoyi-device:modelcamgroup:edit")
    @Log(title = "摄像头分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TModelcamgroup tModelcamgroup)
    {
        return toAjax(tModelcamgroupService.updateTModelcamgroup(tModelcamgroup));
    }

    /**
     * 删除摄像头分组
     */
    @Operation(summary = "删除摄像头分组", description = "删除摄像头分组")
    @RequiresPermissions("ruoyi-device:modelcamgroup:remove")
    @Log(title = "摄像头分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tModelcamgroupService.deleteTModelcamgroupByIds(ids));
    }

    /**
     * 根据fId查询到监控分组保存摄像头信息
     */
    @Operation(summary = "根据fId查询到监控分组保存摄像头信息", description = "根据fId查询到监控分组保存摄像头信息")
    @RequiresPermissions("ruoyi-device:modelcamgroup:edit")
    @Log(title = "摄像头分组", businessType = BusinessType.UPDATE)
    @PutMapping("/config")
    public AjaxResult editCamMyInfo(@RequestBody TModelcamgroup tModelcamgroup)
    {
        return toAjax(tModelcamgroupService.updateTModelcamgroupMyInfo(tModelcamgroup));
    }
}
